{% extends "base.html" %}

{% block title %}编辑角色 - 管理系统{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h4 class="mb-0">编辑角色</h4>
            </div>
            <div class="card-body">
                <form method="POST" action="{{ url_for('admin.edit_role', role_id=role.id) }}">
                    <div class="mb-3">
                        <label for="name" class="form-label">角色名称</label>
                        <input type="text" class="form-control" id="name" name="name" value="{{ role.name }}" required>
                    </div>
                    <div class="mb-3">
                        <label for="description" class="form-label">描述</label>
                        <input type="text" class="form-control" id="description" name="description" value="{{ role.description }}">
                    </div>
                    <div class="mb-3">
                        <label class="form-label">权限</label>
                        {% for permission in permissions %}
                        <div class="form-check">
                            <input class="form-check-input" type="checkbox" name="permissions" value="{{ permission.id }}" id="permission{{ permission.id }}"
                                {% if permission in role.permissions %}checked{% endif %}>
                            <label class="form-check-label" for="permission{{ permission.id }}">
                                {{ permission.name }} - {{ permission.description }}
                            </label>
                        </div>
                        {% endfor %}
                    </div>
                    <button type="submit" class="btn btn-primary">更新角色</button>
                    <a href="{{ url_for('admin.roles') }}" class="btn btn-secondary">返回</a>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 